﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace MiniOrderSystem.Data.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MINI_BOOK",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    BookNo = table.Column<string>(nullable: false),
                    Author = table.Column<string>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    Picture = table.Column<string>(nullable: true),
                    BookType = table.Column<string>(nullable: false),
                    CommodityId = table.Column<string>(maxLength: 32, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_BOOK", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MINI_COMMODITY",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Qty = table.Column<int>(nullable: false),
                    TotalQty = table.Column<int>(nullable: false),
                    Price = table.Column<decimal>(nullable: false),
                    State = table.Column<string>(nullable: true),
                    CommodityTypeId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_COMMODITY", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MINI_COMMODITY_TYPE",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    CommodityTypeNo = table.Column<string>(nullable: true),
                    Type = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_COMMODITY_TYPE", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MINI_ORDER",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    OrderNo = table.Column<string>(nullable: true),
                    State = table.Column<string>(nullable: true),
                    Cancelled = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_ORDER", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MINI_ORDER_ITEM",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    OrderId = table.Column<string>(nullable: true),
                    CommodityId = table.Column<string>(nullable: true),
                    Qty = table.Column<int>(nullable: false),
                    Price = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_ORDER_ITEM", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MINI_USER",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 32, nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Account = table.Column<string>(nullable: true),
                    Password = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MINI_USER", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MINI_BOOK");

            migrationBuilder.DropTable(
                name: "MINI_COMMODITY");

            migrationBuilder.DropTable(
                name: "MINI_COMMODITY_TYPE");

            migrationBuilder.DropTable(
                name: "MINI_ORDER");

            migrationBuilder.DropTable(
                name: "MINI_ORDER_ITEM");

            migrationBuilder.DropTable(
                name: "MINI_USER");
        }
    }
}
